import { setCookiesToken } from '@/utils/auth'
import { defineStore } from 'pinia'
import { ref } from 'vue'

// 用户模块
export const useUserStore = defineStore(
  'user',
  () => {
    const token = ref<string>('') // 定义 token
    const setToken = (t: string) => {
      token.value = t // 设置 token
      setCookiesToken(t)
    }

    return { token, setToken }
  },
  {
    persist: true // 持久化
  }
)
